home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: Application.h
- *
- * Contains: xxx put contents here xxx
- *
- * Written by: Rick Violet
- *
- * Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
- *
- * Change History (most recent first):
- *
- * 11/18/92 RV xxx put comment here xxx
- *
- * To Do:
- */
-
- #ifndef __Application__
- #define __Application__
-
- #include <Types.h>
- #include <Events.h>
- #include <Desk.h>
- #include <OSUtils.h>
- #include <String.h>
- #include <AppleEvents.h>
-
- #include "Application.R.h"
-
- #ifndef __Object__
- #include "Object.h"
- #endif
-
- #ifndef __THREADS__
- #include "Threads.h"
- #endif
-
- pascal OSErr AEOpenHandler (AppleEvent*, AppleEvent*, long );
- pascal OSErr AEOpenDocHandler (AppleEvent*, AppleEvent*, long );
- pascal OSErr AEPrintHandler (AppleEvent*, AppleEvent*, long );
- pascal OSErr AEQuitHandler (AppleEvent*, AppleEvent*, long );
-
-
- //—————————————————————————————————————————————————————————————————————————————————————
- // Application class - Implements a basic System Seven application
- // with handlers for the minimum 4 Apple Events
- // plus the VU external tool service Apple event.
- //—————————————————————————————————————————————————————————————————————————————————————
- class Application : public Object
- {
- private: Boolean fIsThreaded; // Thread Manager or Package is present
- private: Boolean fDone; // set to true when we are ready to quit
- private: EventRecord fTheEvent; // our event record
- private: WindowPtr fWhichWindow; // currently active window
- private: Boolean fInBackground; // true if our app is suspended
- private: Boolean fWantFrontClicks; // true if we want front clicks
- private: long fCursorTicks; // used to spin the cursor
- private: ProcessInfoRec fProcessInfo; // Process info for this application
- private: long fSleepTicks; // Sleep ticks for WaitNextEvent
- public: Str31 fProcessName; // Name of this application
-
- /*SBR Hacked this in 12/03/94 to fix an alleged AE Manager bug */
- public: AppleEvent* fMessagePtrOrig; //———— the original from AE Manager before copying
- public: AppleEvent* fReplyPtrOrig; //———— the original from AE Manager before copying
-
- /*SBR Hacked this in 10/16/94 */
- //———— Create RequestDispatcher; use a separate thread if application is threaded
- private: void CreateRequestDispatcher();
- public: long SetSleepTicks( long pSleepTicks );
- public: Boolean IsThreaded(){ return fIsThreaded; };
-
- public: Application(void); //———— Constructor
- public: virtual ~Application(void); //———— Destructor
- public: void Run(); //———— the main event loop
- public: Boolean DoEvent( unsigned long pSleepTicks = 0, short pEventMask = everyEvent ); //———— handle one event
- public: void DoMenuCommand( short menuID, short menuItem ); //———— Do a menu Request
- public: void SpinTheCursor();
-
- //———— Loop control methods you may need to override
- protected: virtual OSErr InstallRequiredAEHandlers(void);
- protected: virtual void ExitLoop(void); // to exit application, call this routine
-
- //———— event handlers methods you may want to override
- protected: virtual void DoMouseDown(void); // Calls DoContent, DoGrow, DoZoom, etc
- protected: virtual void DoKeyDown(void); // also called for autokey events
- protected: virtual void DoOSEvent(void); // Calls DoSuspend, DoResume and DoIdle as apropos
- protected: virtual void DoHighLevelEvent(void); // calls AEProcessAppleEvents
-
- protected: void DoMouseInSysWindow(void) { SystemClick(&fTheEvent, fWhichWindow); }
-
- protected: virtual unsigned long SleepVal(void); //———— how long to sleep in WaitNextEvent
- protected: void InitializeToolBox(void); //———— Init ToolBox
- protected: void GetThisProcessInfo(void); //———— get Process info for this app
- protected: Boolean TrapAvailable(short tNumber,TrapType tType); //———— Is trap implemented???
- protected: void Terminate(void);
-
- /*SBR Hacked this in 12/03/94 to fix an alleged AE Manager bug */
- void FixAEManagerBugPart2();
-
- };
-
- //———— call TerminalError to display error message, then ExitShell...
- void TerminalError(short errResID, short errCode);
-
- /*SBR Hacked this in 10/16/94 */
- //———— Entry point for RequestDispatcher thread
- void* RequestDispatcherThread(void *threadParam);
-
- #endif
-